package test;

import java.util.Scanner;

public class huawei {
    public static  void show(){
        int stu[];
        Scanner input=new Scanner(System.in);
        int get1=input.nextInt();
        int get2=input.nextInt();
        stu=new int[get1];
        System.out.println("请输入学生成绩（注意要输入"+get1+"个学生的成绩");
        Scanner input2=new Scanner(System.in);
        for (int i=0;i<get1;i++){
            stu[i]=input2.nextInt();
            System.out.println("第"+i+"位学生的成绩为"+stu[i]);
        }
        System.out.println("成绩输入完毕，请输入操作（操作次数为"+get2+"次");
        for (int k=0;k<get2;k++){
            Scanner input3=new Scanner(System.in);
            String intC=input3.next();
            if (intC.equals("Q")){
                System.out.println("执行查询操作");
                int intn=input3.nextInt();
                int intm=input3.nextInt();
                int max=query(intn,intm,stu);
                System.out.println(max);
            }
            if(intC.equals("U")){
                System.out.println("执行更新操作");
                int intn=input3.nextInt();
                int intm=input3.nextInt();
                stu[intn]=intm;
                System.out.println("第"+intn+"号学生的成绩被改为"+intm);
            }
        }
        System.out.println("运行完毕");
    }
    public static int query(int n,int m,int[] stu){
        if (n>m){
            System.out.println("输入错误！");
            return -1;
        }else {
            int max=stu[n];
            for (;n<m;n++){
                if (stu[n]>max){
                    max=stu[n];
                }
            }
            return max;
        }
    }

    public static   void main(String[] args) {
        show();
    }
}
